const CryptoJS = require('crypto-js');

const key = CryptoJS.enc.Utf8.parse('jw');

/**
 * 加密
 */
const encode = function (str) {
  return CryptoJS.DES.encrypt(str, key, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  }).toString();
};

/**
 * 解密
 */
const decode = function (str) {
  return CryptoJS.DES.decrypt(str, key, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  }).toString(CryptoJS.enc.Utf8);
};

// const str = 'http://localhost:4001/js/curry.js';
const str = 'http://192.168.11.26:5002/dcv-api/user/oauth/login';
const after = encode(str);
console.log(after);

console.log(decode(after));
